package com.dynamic.mybatis.core.enums;

import com.dynamic.mybatis.core.toolkit.StringUtils;

/**
 * @Description
 * @Author xs
 * @Date 2021/3/24 17:22
 */
public interface ReturnType {

    String name();
    String getType();
    String returnType();

    enum StandardReturnType implements ReturnType{
        //集合、分页、对象
        COLLECT("collect"),
        PAGE("page"),
        MAP("map"),
        STRING("string"),
        BOOLEAN("boolean"),
        NUMBER("number"),
        BYTE("byte"),
        SHORT("short"),
        INTEGER("int"),
        LONG("long"),
        FLOAT("float"),
        DOUBLE("double"),
        DATE("date"),
        VOID("void"),
        UNKNO(""),
        ;
        public String type;

        StandardReturnType(String type) {
            this.type = type;
        }

        public String getType() {
            return type;
        }
        public String returnType() {
            return this.name();
        }

        public void setType(String type) {
            this.type = type;
        }


    }

    static ReturnType getReturnType(String returnType){
        if(StringUtils.isBlank(returnType)){
            return null;
        }
        for(ReturnType rt : StandardReturnType.values()){
            if(returnType.equalsIgnoreCase(rt.getType())){
                return rt;
            }
        }
        return null;
    }

}